import http from "http"
import {
	renderHTML
} from "./modules/renderHTML.js"

// 路由路径列表
var arr = ["/a", '/b', '/c']
const serve = http.createServer((req, res) => {

	if (req.url === "/favicon.ico") {
		return
	}

	res.writeHead(renderState(req.url, arr), {
		"Content-Type": "text/html;charset=utf-8"
	})

	res.write(renderHTML(req.url))

	// 浏览器请求路径(网址端口号后路径)
	console.log(req.url)
	res.end()
}).listen(3000, () => {
	console.log("server start")
})




// 返回响应状态码
function renderState(url, arr) {
	return arr.includes(url) ? 200 : 404
}
